

var Mock = require('mockjs');
const { Random } = require('mockjs');


/* 加载模板 */
let path =null;


// 机构通讯录列表
path ='./org/org_address_list.js'

// 团队通讯录列表
path ='./org/team_address_list.js'

// 机构客户-已分配列表
path = './org/org_customer_hasAlloc_list.js'

// 机构客户-未分配列表
path = './org/org_customer_noAlloc_list.js'

// 机构渠道-已分配列表
path ='./org/org_channel_hasAlloc_list.js'

// 机构渠道-未分配列表
path ='./org/org_channel_noAlloc_list.js'



var doc = require(path);

/* 生产mock数据 */
var data = Mock.mock(doc)
var jsonString =  JSON.stringify(data);

console.log(jsonString);

/* 导出json */
var fs = require('fs');

let pathList = path.split('/');
let fileName = pathList[pathList.length-1];
let fileNameList = fileName.split(".");
fileName = fileNameList[0];

fs.writeFile(`${fileName}.json`, jsonString, function(err) {
  if(err) {
      return console.log(err);
  }
  console.log("The file was saved!");
});

